package cn.sylinx.common.ext;
/**
 * redis 键工具
 * 
 * @author han
 *
 */
public class KeysHelper {

	public static final String KEY_SEPARATOR = ":";

	/**
	 * 创建键
	 * 
	 * @param objects
	 * @return
	 */
	public static String createKVSKey(Object... objects) {
		StringBuilder sb = new StringBuilder();
		Boolean isFirst = true;

		for (Object o : objects) {
			if (!isFirst) {
				sb.append(KEY_SEPARATOR);
			}
			sb.append(o);
			isFirst = false;
		}

		return sb.toString();
	}

	private static final String KEYS_KEY = "keys";

	/**
	 * 创建键keys
	 * 
	 * @param name
	 * @param objects
	 * @return
	 */
	public static String createKSKey(String name, Object... objects) {
		StringBuilder sb = new StringBuilder();
		sb.append(KEYS_KEY);
		sb.append(KEY_SEPARATOR);
		sb.append(name);

		for (Object o : objects) {
			sb.append(KEY_SEPARATOR);
			sb.append(o);
		}

		return sb.toString();
	}
}
